<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>汉旺人民医院HIS系统</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<style type="text/css" >

* { 
    padding:0;
    margin:0;
	border:0;
	font-size:13px;
	
}

body{
    background-color: #408bab;
	background-image:url(images/login/bg.jpg);
	background-repeat:repeat-x;
	height:768px;
	width:100%;
 
}



.box{
  width:856px;
  margin:0 auto;
  position:relative;
  height:666px;
  }
  
  
.text1{
	position:absolute;
	top:349px;
	left:353px;
}

.text2{
	position:absolute;
	top:394px;
	left:328px;
}

.bumen{
	position:absolute;
	top:359px;
	left:328px;
}

.text3{
	position:absolute;
	top:349px;
	left:545px;
}

.text4{
	position:absolute;
	top:434px;
	left:328px;
	border:1px solid #7f9db9;
}
.text5{
   position:absolute;
   top:470px;
   left:320px;
  border:0px solid #606060;
}

.bumentext{
	position:absolute;
	top:359px;
	left:328px;
	border:1px solid #7f9db9;
}

.tools{
position:absolute;
top:410px;
left:524px;
}

.tools a{
	color:#00499E;
	text-decoration: none;
}


.btn1  a {
	background-image:url(images/login/login.jpg);
	position:absolute;
	width:58px;
	height:59px;
	top:391px;
	left:507px;
	cursor:pointer;
}

.btn1  a:hover{
	background-image:url(images/login/login1.jpg);
	position:absolute;
	width:58px;
	height:59px;
	top:373px;
	left:492px;
	cursor:pointer;
}

.lb_bumen{
	position:absolute;
	top:359px;
	left:265px;
}

.username{
	position:absolute;
	top:396px;
	left:265px;
}

.password{
	position:absolute;
	top:434px;
	left:265px;
}

.treebtn  a {
	background-image:url(images/login/bm.gif);
	position:absolute;
	width:22px;
	height:23px;
	top:355px;
	left:482px;
	cursor:pointer
}

.treebtn  a:hover{
	background-image:url(images/login/bm1.gif);
	position:absolute;
	width:22px;
	height:23px;
	top:348px;
	left:542px;
}
</style>
<script type="text/javascript">
   function doLogin(){
     var deptid=document.getElementById("department").value;
     if(deptid==""||"null"==deptid){
        alert("请选择部门！");
        return false;
     }
     var password=document.getElementById("password").value;
     if(password==""||"null"==password){
        alert("请输入密码！");
        return false;
     }
     document.fm1.submit();
   }
   
   
   function deptSelTree(userid){
	 var peopleid = showModalDialog("/chis/manager/login!editDepart.action?deptid=-1"+"&Random="+Math.random(),"选项分配","dialogHeight:340px;dialogLeft:490px;dialogWidth:300px;dialogTop:250px;help=0;status=0;");
         if(typeof(peopleid)=="undefined"){ 
               return;
          }else{
           var returnValue=peopleid.split("#");
            if(returnValue.length>1){
               var deptid=returnValue[0];
               var deptname=returnValue[1];
               document.getElementById("department").value=deptname;
               checkboxSelProcess(deptid);
            }
          }
    }
</script>
</head>
<%
 String loginState=String.valueOf(request.getAttribute("loginstate"));//0:用户不存在；1：密码不正确；2：登录验证成功
 String loginMessage="";
 if("0".equals(loginState)){
   loginMessage="注：用户不存在，请重新选择！";
 }
 if("1".equals(loginState)){
   loginMessage="注：密码不正确，请重新输入！";
 }
 
 List deptList = new ArrayList();
 //com.hwhp.service.console.DepartService deptService = new com.hwhp.service.console.impl.DepartServiceImpl();
// com.hwhp.service.UserService us = new com.hwhp.service.impl.UserServiceImpl();
 //System.out.println("userService :"+us.getAllUser().size());
 //deptList = deptService.getAllDept();
 
 //System.out.println("deptList size :"+deptList.size());
 
 %>
<body style="MARGIN: 0px;" scroll="no">
<form name="fm1" action="/chis/manager/login!indexLoginProcess.action" method="post" onsubmit="return validate()">
<div class="box">
   <img src="images/login/main4.jpg" width="856" height="666" />
     <div class="text2">
       <select name="user" id="user" style="width: 147px;">
       </select>
    </div>
    <div class="bumentext" id="bumen">
      <input id="department" name="department" type="text" readonly="true" style="width:145px"/>
    </div>
    <div class="treebtn"><a onclick="deptSelTree()" title="选择部门"></a></div>
    <div class="text4">
      <input type="password" size="17" id="password" name="password" onkeydown="if(window.event.keyCode==13) doLogin()" style="width:145px"/>
    </div>
     <div class="text5">
	    <span><font color="red"><%=loginMessage %></font></span>
	</div>
	 <div class="btn1"><a onclick="doLogin()" title="登陆系统"></a></div>
    <div class="lb_bumen">部&nbsp;&nbsp;&nbsp;&nbsp;门：</div>
    <div class="username">用户名：</div>
    <div class="password">密&nbsp;&nbsp;&nbsp;&nbsp;码：</div>
</div>
 </form>
</body>
</html>
<script type="text/javascript">
	  //构造xmlhttp方法
function getXMLHTTPRequest() {
	if (typeof XMLHttpRequest != "undefined") 
	{
	  return new XMLHttpRequest();
	} 	
	else if (window.ActiveXObject) 
	{
		
		var oXmlHttp = new ActiveXObject("MSXML2.XMLHttp.3.0");
		return oXmlHttp;		
	}
	else {
		alert("浏览器不支持xmlhttp，请用高版本的IE或Firefox");
		return null;		
	}
}

//调用子类
function checkboxSelProcess(departmentid) {
  		xmlHttp = getXMLHTTPRequest();
		xmlHttp.onreadystatechange = onReadyStateChange;
		var url = "<%=basePath%>login/department?departmentid="+ departmentid+"&Random="+Math.random();	
		xmlHttp.open("GET", url);
		xmlHttp.send();
}

function onReadyStateChange() {
	var ready = xmlHttp.readyState;
	if (ready == 4) {
		var xmlDoc = xmlHttp.responseXML; 
		var nodeIdSet=xmlDoc.getElementsByTagName('node');
		var userSelObj=document.getElementById("user");
		    userSelObj.length=0;
		for(var i=0;i<nodeIdSet.length;i++){
		     var userNoteId=nodeIdSet[i].getAttribute("value");
		     var userNoteName=nodeIdSet[i].getAttribute("attr");
		     var processObj =document.createElement("OPTION"); 
			     processObj.text = userNoteName;
			     processObj.value = userNoteId;
	         userSelObj.add(processObj);
		}
		userSelObj.selectedIndex=0;
	}
	else
	 ;
}
	</script>
